package com.harlan.viewbindingstudy;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.Display;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.harlan.viewbindingstudy.databinding.MyDialogBinding;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;

class MyDialog extends Dialog {
    protected View mView;
    protected MyDialogBinding mBinding;

    public MyDialog(@NonNull Context context) {
        super(context,R.style.Dialog);
        mBinding = MyDialogBinding.inflate(getLayoutInflater());
        mView = mBinding.getRoot();

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(mView);
        Window window = this.getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        Display d = window.getWindowManager().getDefaultDisplay();
        lp.width = (int) (d.getWidth() * 0.9F);
        window.setAttributes(lp);
    }


}
